<template>
	<view class="page">
    <view class="card">
      <view class="header">
        <div class="title">
          已为您生成10个汉字
        </div>
        <div class="tag">
          1/10
        </div>
      </view>
      <div class="legend-list">
        <div class="legend-item">
          <div class="rect failed"></div>
          <div class="rect-text failed">读错</div>
        </div>
        <div class="legend-item">
          <div class="rect"></div>
          <div class="rect-text">漏读</div>
        </div>
      </div>
      <div class="word-list">
        <div class="word-item-wrapper" v-for="item in wordList">
          <div :class="['word-item', item.failed ? 'failed' : '']">
            <div class="word">{{ item.pinyin }}</div>
            <div class="word-canvas">
              <div :class="['word-text', item.failed ? 'failed' : '', item.miss ? 'miss' : '']">{{ item.text }}</div>
            </div>
          </div>
        </div>
      </div>
    </view>
    <view class="card">
      <view class="header">
        <div class="title">
          已为您生成6组词语
        </div>
        <div class="tag">
          1/10
        </div>
      </view>
      <div class="legend-list">
        <div class="legend-item">
          <div class="rect failed"></div>
          <div class="rect-text failed">读错</div>
        </div>
        <div class="legend-item">
          <div class="rect"></div>
          <div class="rect-text">漏读</div>
        </div>
      </div>
      <div class="word-list">
        <div class="word-item-wrapper" v-for="item in wordList2">
          <div :class="['word-item', item.failed ? 'failed' : '']">
            <div class="word">{{ item.pinyin }}</div>
            <div class="word-canvas">
              <div :class="['word-text', item.failed ? 'failed' : '', item.miss ? 'miss' : '']">{{ item.text }}</div>
            </div>
          </div>
        </div>
      </div>
    </view>
    <view class="card">
      <view class="header">
        <div class="title">
          已为您生成 1篇短 文
        </div>
        <div class="tag">
          1/10
        </div>
      </view>
      <div class="legend-list">
        <div class="legend-item">
          <div class="rect failed"></div>
          <div class="rect-text failed">读错</div>
        </div>
        <div class="legend-item">
          <div class="rect"></div>
          <div class="rect-text">漏读</div>
        </div>
      </div>
      <div class="word-list">
        <div class="word-item-wrapper" v-for="item in wordList2">
          <div :class="['word-item', item.failed ? 'failed' : '']">
            <div class="word">{{ item.pinyin }}</div>
            <div class="word-canvas">
              <div :class="['word-text', item.failed ? 'failed' : '', item.miss ? 'miss' : '']">{{ item.text }}</div>
            </div>
          </div>
        </div>
      </div>
    </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
        // 单词列表
        wordList: [
          {
            text: '我',
            pinyin: 'wǒ',
          },
          {
            text: '爱',
            pinyin: 'ài',
            failed: true,
          },
          {
            text: '你',
            pinyin: 'nǐ',
            miss: true,
          },
          {
            text: '们',
            pinyin: 'men',
          },
          {
            text: '们',
            pinyin: 'men',
          }
        ],
        wordList2: [
          {
            text: '我',
            pinyin: 'wǒ',
          },
          {
            text: '爱',
            pinyin: 'ài',
            failed: true,
          },
          {
            text: '你',
            pinyin: 'nǐ',
            miss: true,
          },
          {
            text: '们',
            pinyin: 'men',
          },
          {
            text: '们',
            pinyin: 'men',
          },
          {
            text: '我',
            pinyin: 'wǒ',
          },
          {
            text: '爱',
            pinyin: 'ài',
            failed: true,
          },
          {
            text: '你',
            pinyin: 'nǐ',
            miss: true,
          },
          {
            text: '们',
            pinyin: 'men',
          },
          {
            text: '们',
            pinyin: 'men',
          }
        ],
			}
		},
		methods: {

		}
	}
</script>

<style scoped>
.page {
  overflow-y: auto;
  padding: 0 16px;
  .card {
    box-shadow: 0px 5px 28px 0px rgba(0, 3, 72, 0.1);
    background-color: #ffffff;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
  }
  .word-list {
    display: flex;
    flex-wrap: wrap;
    .word-item-wrapper {
      width: 20%;
      padding: 0 8px;
      margin-bottom: 16px;
    }
    .word-item {
      display: flex;
      flex-direction: column;
      justify-content: center;
      .word {
        font-size: 12px;
        font-weight: bold;
        text-align: center;
        margin-bottom: 8px;
      }
      .word-canvas {
        padding: 12px;
        position: relative;
        width: 55px;
        height: 55px;
        background-image: url("/static/米字格.png");
        background-repeat: no-repeat;
        background-size: 100% 100%;
        .word-text {
          position: absolute;
          // 居中
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          font-size: 30px;
          color: #333333;
          &.failed {
            color: #FF6C6C;
          }
          // 漏读
          &.miss {
            color: #999;
          }
        }
      }
    }
  }
  .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    .title {
      font-size: 14px;
    }
    .tag {
      // 横向渐变
      background: linear-gradient(90deg, #73ACFF 0%, #73DDFF 100%);
      height: 24px;
      line-height: 24px;
      border-radius: 12px;
      padding: 0 20px;
      text-align: center;
      font-size: 12px;
      color: #ffffff;
    }
  }
  .legend-list {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 16px;
    .legend-item {
      margin-left: 16px;
      display: flex;
      align-items: center;
      .rect {
        width: 12px;
        height: 12px;
        margin-right: 6px;
        background-color: #999;
        &.failed {
          background-color: #FF6C6C;
        }
      }
      .rect-text {
        font-size: 12px;
        color: #999;
        &.failed {
          color: #FF6C6C;
        }
      }
    }
  }
}
</style>
